import { strictEqual } from "assert";
import { solar2lunar, lunar2solar, lunarMonthAdd, verifyLunarDate } from "../src/ts/utils-lunar";
const lunar = require('chinese-lunar');


describe("test-lunar-solar", async function () {

	it('time-solar-to-lunar', async function () {
		let lunarDate = solar2lunar(new Date(2018, 11, 6));
		strictEqual(lunarDate.year, 2018);
		strictEqual(lunarDate.month, 10);
		strictEqual(lunarDate.day, 29);

		lunarDate = solar2lunar(new Date(2018, 12, 6));
		strictEqual(lunarDate.year, 2018);
		strictEqual(lunarDate.month, 12);
		strictEqual(lunarDate.day, 1);
	});


	it('time-lunar-to-solar', async function () {
		let solarDate = lunar2solar({ year: 2018, month: 12, day: 1 });
		strictEqual(solarDate.year(), 2019);
		strictEqual(solarDate.month(), 0);
		strictEqual(solarDate.date(), 6);

		solarDate = lunar2solar({ year: 2019, month: 4, day: 30 });
		strictEqual(solarDate.year(), 2019);
		strictEqual(solarDate.month(), 5);
		strictEqual(solarDate.date(), 3);
	});


	it('time-month-add', async function () {
		const lunar1 = { leap: false, year: 2018, month: 4, day: 20, leapMonth: 0 };
		const lunar2 = lunarMonthAdd(lunar1, 18);
		const lunar3 = lunarMonthAdd(lunar1, 19);
		const lunar4 = lunarMonthAdd(lunar1, 20);
		strictEqual(lunar2.month + 1, lunar3.month);
		strictEqual(lunar3.month + 1, lunar4.month);
	});


});